
import NavBar from '../components/nav-bar/index.vue'
import TabBar from '../components/tab-bar/index.vue'
// 路由懒加载写法
const Home = () => import('../views/home/index.vue')
const Category = () => import('../views/category/index.vue')
const Login = () => import('../views/login/index.vue')
const Cart = () => import('../views/cart/index.vue')
const Detail = () => import('../views/detail/index.vue')
const Mine = () => import('../views/mine/index.vue')
const NotFound = () => import('../views/not-found/index.vue')
const Register = () => import('../views/register/index.vue')

const routes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        components: {
            default: Home,
            footer: TabBar,
        },
        meta: {
            title: '首页',
            icon: 'wap-home-o',
            inTabbar: true, // 标记当前路由需要作为 tabbar 中的 tab项渲染
        }
    },
    {
        path: '/category',
        components: {
            header: NavBar,
            default: Category,
            footer: TabBar
        },
        meta: {
            title: '分类',
            icon: 'apps-o',
            inTabbar: true,
        }
    },
    {
        path: '/cart',
        components: {
            header: NavBar,
            default: Cart,
            footer: TabBar
        },
        meta: {
            title: '购物车',
            icon: 'cart-o',
            inTabbar: true,
            badge: true, // 购物车标记显示
            needLogin: true, // 是否登录后访问
        }
    },
    {
        path: '/mine',
        components: {
            header: NavBar,
            default: Mine,
            footer: TabBar
        },
        meta: {
            title: '我的',
            icon: 'contact-o',
            inTabbar: true,
            needLogin: true,
        }
    },
    {
        path: '/detail',
        components: {
            header: NavBar,
            default: Detail
        },
        meta: {
            title: '商品详情',
            needLogin: true,
        }
    },
    {
        path: '/login',
        components: {
            header: NavBar,
            default: Login
        },
        meta: {
            title: '登录'
        }
    },
    {
        path: '/register',
        components: {
            header: NavBar,
            default: Register
        },
        meta: {
            title: '用户注册'
        }
    },
    {
        path: '/:PathMatch(.*)*',
        component: NotFound,
    },
]

export default routes